<template>
  <div v-show="props.compType === 'inputNumber'">
    <el-form-item label="ID">
      <el-tooltip
          class="item"
          effect="dark"
          content="请注意,ID的修改可能会导致该组件相关事件失效！"
          placement="left"
      >
        <el-input class="input" v-model="props.id" @change="handlerChangeGetId"></el-input>
      </el-tooltip>
    </el-form-item>
    <el-form-item label="标题">
      <el-input class="input" v-model="props.label"></el-input>
    </el-form-item>
    <el-form-item label="栅格间隔">
      <el-input-number v-model="props.gutter" :min="0"></el-input-number>
    </el-form-item>
    <el-form-item label="标签宽度">
      <el-input-number v-model="props.labelWidth" :min="1" :max="200"></el-input-number>
    </el-form-item>
    <el-form-item label="显示标签">
      <el-switch v-model="props.showLabel" @change="handlerChangeLabel"></el-switch>
    </el-form-item>
    <el-form-item label="必填">
      <el-switch v-model="props.required"></el-switch>
    </el-form-item>
    <el-form-item label="最小值">
      <el-input-number v-model="props.min"></el-input-number>
    </el-form-item>
    <el-form-item label="最大值">
      <el-input-number v-model="props.max"></el-input-number>
    </el-form-item>
    <el-form-item label="步长">
      <el-input-number v-model="props.step"></el-input-number>
    </el-form-item>
    <el-form-item label="精度">
      <el-input-number v-model="props.precision" :min="0" :max="10"></el-input-number>
    </el-form-item>
    <el-form-item label="按钮位置">
      <el-radio-group v-model="props['controls-position']">
        <el-radio-button value="">默认</el-radio-button>
        <el-radio-button value="right">右侧</el-radio-button>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="禁用">
      <el-switch v-model="props.disabled" @change="handlerChangeDisStatus('disabled')"></el-switch>
    </el-form-item>
    <el-form-item label="默认值">
      <el-input-number class="input" v-model="props.modelValue"></el-input-number>
    </el-form-item>
  </div>
</template>
<script lang="ts">
import {changeId, type FormDesignerMixin} from '../mixin/FormDesignerMixin';
import {Component, Prop} from 'web-decorator-vue';
@Component({
  name: 'input-number',
  mixins: [changeId],
})
export default class InputNumber implements FormDesignerMixin  {
  // TODO 补齐作用
  @Prop() props: any;
  // TODO 补齐作用
  @Prop() getFormId: any;
  // TODO 补齐作用
  handlerChangeLabel(val:any) {
    this.props.labelWidth = val ? 80 : 1;
  }
  // TODO 补齐作用
  handlerChangeDisStatus(val:any) {
    this.props.readOnly = val ? false : true;
  }
  // TODO 补齐注释
  // 数据属性
  handlerChangeIdCallback?: Function;
  
  // 方法
  handlerChangeGetId(val: any) {
    if (this.handlerChangeIdCallback) {
      this.handlerChangeIdCallback(val);
    }
  }
}
</script>
<style scoped>
.input {
  width: 75%;
}
</style>
